home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
answrbok
/
7_10.lha
/
7_10
/
p_runtask.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-08
|
2KB
|
54 lines
* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
* The C++ Answer Book */
* Tony Hansen */
* All rights reserved. */
include <process.h>
include <debug.h> /* DELETE */
/ Run the given process
oid process::exec()
if (debug) /*DELETE*/ cerr << "process" << this << "::exec()\n";
char x;
char *px = &x;
if (t_stackbase == 0)
{
if (debug) /*DELETE*/ cerr << "---- setting t_stackbase <- ";
if (debug>1) /*DELETE*/ cerr << form("%#x", &x);
if (debug) /*DELETE*/ cerr << "\n";
t_stackbase = px;
}
if (debug) /*DELETE*/ cerr << "t_stackbase == ";
if (debug>1)/*DELETE*/ cerr << form("%#x", t_stackbase);
if (debug) /*DELETE*/ cerr << "\n";
if (debug) /*DELETE*/ cerr << "st::plusone == ";
if (debug>1)/*DELETE*/ cerr << form("%#x", Stackdir.plusone());
if (debug) /*DELETE*/ cerr << "\n";
if (debug) /*DELETE*/ cerr << "st::diff == " << Stackdir.diff(t_stackbase, Stackdir.plusone()) << "\n";
if (Stackdir.less(px, t_stackbase))
exec();
else
{
// parent <- thisprocess
// set the parent as runnable
process *parent = t_thisprocess;
if (debug) /*DELETE*/ cerr << "\tparent == " << parent << "\n";
parent->t_next = t_runprocesses;
t_runprocesses = parent;
parent->t_curstate = TASK_RUNNABLE;
if (debug) /*DELETE*/ cerr << "\t" << parent << "->t_curstate <- " << ps_print(parent->t_curstate) << "\n";
if (!parent->contextswitch())
{ // in child
// child <- thisprocess
t_thisprocess = this;
t_curstate = TASK_RUNNABLE;
if (debug) /*DELETE*/ cerr << "\t" << this << "->t_curstate <- " << ps_print(t_curstate) << "\n";
exit(main());
}
}
if (debug) /*DELETE*/ cerr << "<<<< process" << this << "::exec()\n";